package com.ytzl.itrip.utils.common;

import com.alibaba.fastjson.JSON;
import com.ytzl.itrip.beans.model.ItripUser;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by asus on 2018/7/27.
 */
@Component
public class ValidationUtil {

    @Resource
    private RedisAPI redisAPI;

    public ItripUser getuser(String token){
        try{
            if (!redisAPI.exists(token)){
                return null;
            }
            String itripUserJson = redisAPI.get(token);
            ItripUser itripUser = JSON.parseObject(itripUserJson,ItripUser.class);
            return itripUser;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
}
